#include<iostream>
#include<thread>
#include<mutex>

int share_data = 0;
std::mutex mtx;


void func011(int n) {
	for (size_t i = 0; i < 10000; i++)
	{
		mtx.lock();
		share_data++;
		std::cout << "Thread " << n << " inc shared_data to" << share_data << std::endl;
		mtx.unlock();
	}
}

int main011() {
	std::thread t1(func011,1);
	std::thread t2(func011,2);
	t1.join();
	t2.join();
	std::cout << "Final share_data == " << share_data << std::endl;
	return 0;
}